﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace Guline.Web.XjsGame
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {
            //Content/Detail/923
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
            //public ActionResult Index(int? newsPage)
            routes.MapRoute(
               "gotoCat", // Route name
               "goto/ic{ID}", // URL with parameters
               new { controller = "Content", action = "CGoTo", } // Parameter defaults
               , new { ID = @"\d+" }

           );
          
            //public ActionResult Index(int? newsPage)
            routes.MapRoute(
               "gotocontent", // Route name
               "goto/i{ID}", // URL with parameters
               new { controller = "Content", action = "IGoTo", } // Parameter defaults
               , new { ID = @"\d+" }

           );
          
            //public ActionResult Index(int? newsPage)
            routes.MapRoute(
             "newstype", // Route name
             "{Title}/page-{newsPage}-ic{ID}", // URL with parameters
             new { controller = "Content", action = "Type", } // Parameter defaults
             , new { ID = @"\d+", newsPage = @"\d" }

         );
            routes.MapRoute(
               "newstypei", // Route name
               "{Title}-ic{ID}", // URL with parameters
               new { controller = "Content", action = "Type", } // Parameter defaults
               , new { ID = @"\d+"}

           );
           
            //public ActionResult Index(int? newsPage)
            routes.MapRoute(
               "newscontent", // Route name
               "{Title}-i{ID}", // URL with parameters
               new { controller = "Content", action = "Detail", } // Parameter defaults
               , new { ID = @"\d+" }

           );
      
            //public ActionResult Index(int? newsPage)
            routes.MapRoute(
               "indexPaing", // Route name
               "trang-chu/page-{newsPage}", // URL with parameters
               new { controller = "Home", action = "IndexPaging", } // Parameter defaults
               , new { newsPage=@"\d+" }

           );
            routes.MapRoute(
             "indexHome", // Route name
             "trang-chu", // URL with parameters
             new { controller = "Home", action = "Index"} // Parameter defaults
     

         );
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            // Use LocalDB for Entity Framework by default
            Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}